import router from './index'

const WHITELIST = ['/auth', '/landing', '/callback']

router.beforeEach((to, from, next) => {
    //根据url参数存储access-token
    let token = to.query.token
    let bu = to.query.bu
    let email = to.query.email
    let role = to.query.role
    if (token) {
        sessionStorage.setItem('access-token', token)
    }
    if (bu) {
        sessionStorage.setItem('bu', bu)
    }
    if (email) {
        sessionStorage.setItem('email', email)
    }
    if (role) {
        sessionStorage.setItem('role', role)
    }
    document.title = to.meta.title
    //判断访问页面是否在白名单中（白名单中的页面不进行拦截）
    if (WHITELIST.includes(to.path)) {
        next()
        return
    }

    next()
})

router.afterEach((to, from) => {
})